In many cases, the information collected by HttpWatch consists of collections of items (Pages, Entries, etc.) In these cases, the automation library provides a collection class for each type of item. These collection classes and the types they contain are as follows:
All the collection classes listed above have the following two properties:
In Ruby, the implementation of the Item property allows individual members of the collection to be accessed in two ways:
For example, the following code fragment steps through the Log object's Entries collection and prints out the URL for each Entry:
Using each method with Collection Classes |
Copy Code
|
---|---|
# Loop through each Entry object in the Entries collection log.Entries.each do |entry| # Prints the URL of each entry recorded puts entry.URL endf |
And the following example uses the default method notation to retrieve the first Entry in the Log object's Entries collection:
Accessing Collection Members by Index |
Copy Code
|
---|---|
# Prints the URL of the first entry recorded
puts log.Entries(0).URL
|
Some classes such as Timings and PageEvents do not hold a variable length list of objects. Instead these classes contain a fixed set of named objects. For example, the Timings class has nine properties that return Timing objects representing timings such as the DNS Lookup and Connect timings.